﻿'         This file is Copyright © 2008-2012 Billy O'Neal and Aommaster
'                            All rights reserved.
'
' This file is released under the 2-Clause BSD license, included in LICENSE.TXT
'                           and on the MHWT website
Imports System.ComponentModel

Friend Class ChooseSpeech
    Private WithEvents canDatabase As BindingList(Of Speech) = GlobalData.canDatabase
    Public returnedSpeech As Speech
    Private Sub Cancel_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Cancel_Button.Click
        returnedSpeech = Nothing
        Me.Close()
    End Sub

    Private Sub OK_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OK_Button.Click

        returnedSpeech = CType(cb.SelectedItem, Speech)
        Me.Close()
    End Sub
    Private Sub populate() Handles canDatabase.ListChanged
        cb.Items.Clear()
        For Each item As Speech In canDatabase
            cb.Items.Add(item)
        Next
    End Sub
    Private Sub chooseSpeech_Shown(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Shown
        populate()
    End Sub

    Private Sub cb_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles cb.DoubleClick
        returnedSpeech = CType(cb.SelectedItem, Speech)
        Me.Close()
    End Sub
    Private Sub cb_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cb.SelectedIndexChanged
        Dim curSpeech As Speech = DirectCast(cb.SelectedItem, Speech)
        discBox.Text = curSpeech.Description
    End Sub
End Class
